/**
 * @file		constructor.cpp
 * @description		This example builds on assignBike by adding
 *			a constructor to the class.
 * @course		CSCI 123 Section 00000
 * @assignment 
 * @date		mm/dd/yyyy
 * @author		Brad Rippe (00000000) brippe@fullcoll.edu
 * @version		2.0
 */
#include <iostream>
#include <string>
using namespace std;

/**
 * This is the bike class. The public members and functions
 * are accessible to everyone. The private members and functions
 * are only accessible to the class. 
 */
class Bike {
public:

	/**
	 * This is the default constructor. This constructor
	 * creates a Bike object without specifying any parameters
	 */
	Bike();

	/**
	 * Creates a Bike.
	 * @param aName  sets the bike's name
	 * @param aSize sets the bike's frame size
	 * @param aDiameter sets the bike's wheel diameter
	 */
	Bike(string aName, int aSize, double aDiameter);

	/**
	 * Gets the bike's name.
	 * @return the name of the bike
	 */
	string getName();

	/**
	 * Set the bike's name.
	 * @param aName the name to set the bike's name to.
	 */
	void setName(string aName);

	/**
	 * Gets the bike's name.
	 * @return the name of the bike
	 */
	int getSize();

	/**
	 * Set the bike's frame size.
	 * @param aSize the size to set the bike's frame to.
	 */
	void setSize(int aSize);

	/**
	 * Gets the bike's name.
	 * @return the name of the bike
	 */
	double getWheelDiameter();

	/**
	 * Set the bike's wheel diameter
	 * @param aDiameter the diameter to set the bike's diameter to.
	 */
	void setWheelDiameter(double aDiameter);

private:
	// this is a private function, only this class can access
	// a private function. Private functions are usually utility
	// functions for the class. They won't be accessed by others
	// therefore the documentation can be left out. We only want to
	// explain the api that others can use.
	bool validSize(int aSize);
	string mName;
	int mSize;
	double mWheelDiameter;
};


/**
 * @return zero if the application executes successfully
 */
int main() {

	Bike mtnBike;						// uses the default constructor
	Bike mtnBike2("Foes", 18, 26.0);

	cout << "Mountain Bike " << mtnBike.getName() << endl;
	cout << "has a frame size of " << mtnBike.getSize() << endl;
	cout << "and a wheel diameter of " << mtnBike.getWheelDiameter() << endl;

	cout << "Mountain Bike " << mtnBike2.getName() << endl;
	cout << "has a frame size of " << mtnBike2.getSize() << endl;
	cout << "and a wheel diameter of " << mtnBike2.getWheelDiameter() << endl;

	return 0;
}

// Bike class implementation
// this is usually given in another cpp file
// and the interface (above the main) is usually
// provided in a separate header file
// Default Constructor - no parameters
Bike::Bike() {
	mName = "Unknown Name";
	mSize = 10;
	mWheelDiameter = 12.0;
}

Bike::Bike(string aName, int aSize, double aDiameter) {
	if(aName == "")
		mName = "Unknown Name";
	else
		mName = aName;
	if(aSize <= 0)
		mSize = 10;
	else
		mSize = aSize;
	if(aDiameter <= 4)
		mWheelDiameter = 5.0;
	else
		mWheelDiameter = aDiameter;
}

string Bike::getName() {
	return mName;
}

void Bike::setName(string aName) {
	mName = aName;
}

int Bike::getSize() {
	return mSize;
}

void Bike::setSize(int aSize) {
	if(validSize(aSize))
		mSize = aSize;
	else
		mSize = 10;
}

double Bike::getWheelDiameter() {
	return mWheelDiameter;
}

void Bike::setWheelDiameter(double aDiameter) {
	mWheelDiameter = aDiameter;
}

bool Bike::validSize(int aSize) {
	if(aSize <= 0)
		return false;
	return true;
}

